eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

Visual Studio Code Java Language Server Plugin always goes to shutdown with no reason

Open airbagi opened this issue 2 years ago • 17 comments

Hello,

I installed Language Support for Java(TM) by Red Hat extension for Visual Studio Code (windows platform). JDK 16.0.1 is used on that PC. So after I start VScode it work fine, but after some period of time it causes Java Language Server shutdown. That what is in the log:

[Trace - 17:14:45] Sending request 'initialize - (0)'.
Params: {
    "processId": 10924,
    "clientInfo": {
        "name": "Visual Studio Code",
        "version": "1.58.2"
    },
    "locale": "ru",
    "rootPath": "e:\\PROGRAMMS\\Android\\android-audiorecord-sample",
    "rootUri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": true
                }
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true,
            "semanticTokens": {
                "refreshSupport": true
            },
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            }
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": false,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "insertReplaceSupport": true,
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    },
                    "activeParameterSupport": true
                },
                "contextSupport": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                },
                "honorsChangeAnnotations": false
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true,
                "prepareSupportDefaultBehavior": 1,
                "honorsChangeAnnotations": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "1.1.0"
            }
        }
    },
    "initializationOptions": {
        "bundles": [],
        "workspaceFolders": [
            "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample"
        ],
        "settings": {
            "java": {
                "home": "C:\\Program Files\\Java\\jdk-16.0.1",
                "jdt": {
                    "ls": {
                        "vmargs": "-Dlog.level=ALL"
                    }
                },
                "errors": {
                    "incompleteClasspath": {
                        "severity": "warning"
                    }
                },
                "configuration": {
                    "checkProjectSettingsExclusions": true,
                    "updateBuildConfiguration": "interactive",
                    "maven": {
                        "userSettings": null,
                        "globalSettings": null,
                        "notCoveredPluginExecutionSeverity": "warning"
                    },
                    "runtimes": []
                },
                "trace": {
                    "server": "verbose"
                },
                "import": {
                    "maven": {
                        "enabled": true
                    },
                    "gradle": {
                        "enabled": true,
                        "wrapper": {
                            "enabled": true
                        },
                        "version": null,
                        "home": null,
                        "java": {
                            "home": null
                        },
                        "offline": {
                            "enabled": false
                        },
                        "arguments": null,
                        "jvmArguments": null,
                        "user": {
                            "home": null
                        }
                    },
                    "exclusions": [
                        "**/node_modules/**",
                        "**/.metadata/**",
                        "**/archetype-resources/**",
                        "**/META-INF/maven/**"
                    ]
                },
                "maven": {
                    "downloadSources": false,
                    "updateSnapshots": false
                },
                "eclipse": {
                    "downloadSources": false
                },
                "referencesCodeLens": {
                    "enabled": false
                },
                "signatureHelp": {
                    "enabled": false
                },
                "implementationsCodeLens": {
                    "enabled": false
                },
                "format": {
                    "enabled": true,
                    "settings": {
                        "url": "c:\\Users\\андрей\\.vscode\\extensions\\redhat.java\\eclipse-formatter.xml",
                        "profile": "GoogleStyle"
                    },
                    "comments": {
                        "enabled": true
                    },
                    "onType": {
                        "enabled": true
                    },
                    "insertSpaces": true,
                    "tabSize": 4
                },
                "saveActions": {
                    "organizeImports": false
                },
                "project": {
                    "referencedLibraries": [
                        "lib/**/*.jar"
                    ],
                    "importOnFirstTimeStartup": "automatic",
                    "importHint": false,
                    "resourceFilters": [
                        "node_modules",
                        ".git"
                    ]
                },
                "contentProvider": {
                    "preferred": null
                },
                "autobuild": {
                    "enabled": true
                },
                "maxConcurrentBuilds": 1,
                "recommendations": {
                    "dependency": {
                        "analytics": {
                            "show": true
                        }
                    }
                },
                "completion": {
                    "maxResults": 0,
                    "enabled": true,
                    "overwrite": true,
                    "guessMethodArguments": false,
                    "favoriteStaticMembers": [
                        "org.junit.Assert.*",
                        "org.junit.Assume.*",
                        "org.junit.jupiter.api.Assertions.*",
                        "org.junit.jupiter.api.Assumptions.*",
                        "org.junit.jupiter.api.DynamicContainer.*",
                        "org.junit.jupiter.api.DynamicTest.*",
                        "org.mockito.Mockito.*",
                        "org.mockito.ArgumentMatchers.*",
                        "org.mockito.Answers.*"
                    ],
                    "filteredTypes": [
                        "java.awt.*",
                        "com.sun.*",
                        "sun.*"
                    ],
                    "importOrder": [
                        "java",
                        "javax",
                        "com",
                        "org"
                    ]
                },
                "foldingRange": {
                    "enabled": true
                },
                "progressReports": {
                    "enabled": true
                },
                "codeGeneration": {
                    "hashCodeEquals": {
                        "useJava7Objects": false,
                        "useInstanceof": false
                    },
                    "useBlocks": false,
                    "generateComments": false,
                    "toString": {
                        "template": "${object.className} [${member.name()}=${member.value}, ${otherMembers}]",
                        "codeStyle": "STRING_CONCATENATION",
                        "skipNullValues": false,
                        "listArrayContents": true,
                        "limitElements": 0
                    },
                    "insertionLocation": "afterCursor"
                },
                "selectionRange": {
                    "enabled": true
                },
                "showBuildStatusOnStart": {
                    "enabled": false
                },
                "server": {
                    "launchMode": "Hybrid"
                },
                "sources": {
                    "organizeImports": {
                        "starThreshold": 99,
                        "staticStarThreshold": 99
                    }
                },
                "semanticHighlighting": {
                    "enabled": true
                },
                "imports": {
                    "gradle": {
                        "wrapper": {
                            "checksums": [
                                {
                                    "sha256": "29d5f29629eba6d8acb3ed0a556bc11066e133184b47c8bc01ea52e8a0894ec8",
                                    "allowed": true
                                }
                            ]
                        }
                    }
                },
                "templates": {
                    "fileHeader": [],
                    "typeComment": []
                },
                "references": {
                    "includeAccessors": true,
                    "includeDecompiledSources": true
                },
                "typeHierarchy": {
                    "lazyLoad": false
                },
                "settings": {
                    "url": null
                },
                "symbols": {
                    "includeSourceMethodDeclarations": false
                }
            }
        },
        "extendedClientCapabilities": {
            "progressReportProvider": true,
            "classFileContentsSupport": true,
            "overrideMethodsPromptSupport": true,
            "hashCodeEqualsPromptSupport": true,
            "advancedOrganizeImportsSupport": true,
            "generateToStringPromptSupport": true,
            "advancedGenerateAccessorsSupport": true,
            "generateConstructorsPromptSupport": true,
            "generateDelegateMethodsPromptSupport": true,
            "advancedExtractRefactoringSupport": true,
            "inferSelectionSupport": [
                "extractMethod",
                "extractVariable",
                "extractField"
            ],
            "moveRefactoringSupport": true,
            "clientHoverProvider": true,
            "clientDocumentSymbolProvider": true,
            "gradleChecksumWrapperPromptSupport": true,
            "resolveAdditionalTextEditsSupport": true,
            "advancedIntroduceParameterRefactoringSupport": true,
            "actionableRuntimeNotificationSupport": true,
            "shouldLanguageServerExitOnShutdown": true
        },
        "triggerFiles": [
            "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java"
        ]
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample",
            "name": "android-audiorecord-sample"
        }
    ]
}


WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
[Trace - 17:14:48] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:48 Main thread is waiting"
}


[Info  - 17:14:48] 4 авг. 2021 г., 17:14:48 Main thread is waiting
[Trace - 17:14:48] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:48 >> initialize"
}


[Info  - 17:14:48] 4 авг. 2021 г., 17:14:48 >> initialize
[Trace - 17:14:48] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:48 Initializing Java Language Server 1.2.0.202106301426"
}


[Info  - 17:14:48] 4 авг. 2021 г., 17:14:48 Initializing Java Language Server 1.2.0.202106301426
[Trace - 17:14:48] Received response 'initialize - (0)' in 3376ms.
Result: {
    "capabilities": {
        "textDocumentSync": {
            "openClose": true,
            "change": 2,
            "save": {
                "includeText": true
            }
        },
        "workspace": {
            "workspaceFolders": {
                "supported": true,
                "changeNotifications": true
            }
        }
    }
}


[Trace - 17:14:48] Sending notification 'initialized'.
Params: {}


[Trace - 17:14:48] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": {
        "java": {
            "home": "C:\\Program Files\\Java\\jdk-16.0.1",
            "jdt": {
                "ls": {
                    "vmargs": "-Dlog.level=ALL"
                }
            },
            "errors": {
                "incompleteClasspath": {
                    "severity": "warning"
                }
            },
            "configuration": {
                "checkProjectSettingsExclusions": true,
                "updateBuildConfiguration": "interactive",
                "maven": {
                    "userSettings": null,
                    "globalSettings": null,
                    "notCoveredPluginExecutionSeverity": "warning"
                },
                "runtimes": []
            },
            "trace": {
                "server": "verbose"
            },
            "import": {
                "maven": {
                    "enabled": true
                },
                "gradle": {
                    "enabled": true,
                    "wrapper": {
                        "enabled": true
                    },
                    "version": null,
                    "home": null,
                    "java": {
                        "home": null
                    },
                    "offline": {
                        "enabled": false
                    },
                    "arguments": null,
                    "jvmArguments": null,
                    "user": {
                        "home": null
                    }
                },
                "exclusions": [
                    "**/node_modules/**",
                    "**/.metadata/**",
                    "**/archetype-resources/**",
                    "**/META-INF/maven/**"
                ]
            },
            "maven": {
                "downloadSources": false,
                "updateSnapshots": false
            },
            "eclipse": {
                "downloadSources": false
            },
            "referencesCodeLens": {
                "enabled": false
            },
            "signatureHelp": {
                "enabled": false
            },
            "implementationsCodeLens": {
                "enabled": false
            },
            "format": {
                "enabled": true,
                "settings": {
                    "url": "c:\\Users\\андрей\\.vscode\\extensions\\redhat.java\\eclipse-formatter.xml",
                    "profile": "GoogleStyle"
                },
                "comments": {
                    "enabled": true
                },
                "onType": {
                    "enabled": true
                },
                "insertSpaces": true,
                "tabSize": 4
            },
            "saveActions": {
                "organizeImports": false
            },
            "project": {
                "referencedLibraries": [
                    "lib/**/*.jar"
                ],
                "importOnFirstTimeStartup": "automatic",
                "importHint": false,
                "resourceFilters": [
                    "node_modules",
                    ".git"
                ]
            },
            "contentProvider": {
                "preferred": null
            },
            "autobuild": {
                "enabled": true
            },
            "maxConcurrentBuilds": 1,
            "recommendations": {
                "dependency": {
                    "analytics": {
                        "show": true
                    }
                }
            },
            "completion": {
                "maxResults": 0,
                "enabled": true,
                "overwrite": true,
                "guessMethodArguments": false,
                "favoriteStaticMembers": [
                    "org.junit.Assert.*",
                    "org.junit.Assume.*",
                    "org.junit.jupiter.api.Assertions.*",
                    "org.junit.jupiter.api.Assumptions.*",
                    "org.junit.jupiter.api.DynamicContainer.*",
                    "org.junit.jupiter.api.DynamicTest.*",
                    "org.mockito.Mockito.*",
                    "org.mockito.ArgumentMatchers.*",
                    "org.mockito.Answers.*"
                ],
                "filteredTypes": [
                    "java.awt.*",
                    "com.sun.*",
                    "sun.*"
                ],
                "importOrder": [
                    "java",
                    "javax",
                    "com",
                    "org"
                ]
            },
            "foldingRange": {
                "enabled": true
            },
            "progressReports": {
                "enabled": true
            },
            "codeGeneration": {
                "hashCodeEquals": {
                    "useJava7Objects": false,
                    "useInstanceof": false
                },
                "useBlocks": false,
                "generateComments": false,
                "toString": {
                    "template": "${object.className} [${member.name()}=${member.value}, ${otherMembers}]",
                    "codeStyle": "STRING_CONCATENATION",
                    "skipNullValues": false,
                    "listArrayContents": true,
                    "limitElements": 0
                },
                "insertionLocation": "afterCursor"
            },
            "selectionRange": {
                "enabled": true
            },
            "showBuildStatusOnStart": {
                "enabled": false
            },
            "server": {
                "launchMode": "Hybrid"
            },
            "sources": {
                "organizeImports": {
                    "starThreshold": 99,
                    "staticStarThreshold": 99
                }
            },
            "semanticHighlighting": {
                "enabled": true
            },
            "imports": {
                "gradle": {
                    "wrapper": {
                        "checksums": [
                            {
                                "sha256": "29d5f29629eba6d8acb3ed0a556bc11066e133184b47c8bc01ea52e8a0894ec8",
                                "allowed": true
                            }
                        ]
                    }
                }
            },
            "templates": {
                "fileHeader": [],
                "typeComment": []
            },
            "references": {
                "includeAccessors": true,
                "includeDecompiledSources": true
            },
            "typeHierarchy": {
                "lazyLoad": false
            },
            "settings": {
                "url": null
            },
            "symbols": {
                "includeSourceMethodDeclarations": false
            }
        }
    }
}


[Trace - 17:14:48] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java",
        "languageId": "java",
        "version": 1,
        "text": "/*\r\n * Copyright 2016 the original author or authors.\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\npackage com.example.audiorecord;\r\n\r\nimport android.Manifest;\r\nimport android.content.pm.PackageManager;\r\nimport android.media.AudioFormat;\r\nimport android.media.AudioRecord;\r\nimport android.media.MediaRecorder;\r\nimport android.os.Bundle;\r\nimport android.os.Environment;\r\nimport android.support.v4.app.ActivityCompat;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.util.Log;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\nimport java.io.File;\r\nimport java.io.FileOutputStream;\r\nimport java.io.IOException;\r\nimport java.nio.ByteBuffer;\r\nimport java.util.concurrent.atomic.AtomicBoolean;\r\n\r\n/** Sample that demonstrates how to record a device's microphone using {@link AudioRecord}. */\r\npublic class AudioRecordActivity extends AppCompatActivity {\r\n\r\n  private static final int SAMPLING_RATE_IN_HZ = 44100;\r\n  private static final int RECORD_TIME_MS = 30000;\r\n\r\n  private static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;\r\n\r\n  private static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;\r\n\r\n  /**\r\n   * Factor by that the minimum buffer size is multiplied. The bigger the factor is the less likely\r\n   * it is that samples will be dropped, but more memory will be used. The minimum buffer size is\r\n   * determined by {@link AudioRecord#getMinBufferSize(int, int, int)} and depends on the recording\r\n   * settings.\r\n   */\r\n  private static final int BUFFER_SIZE_FACTOR = 2;\r\n\r\n  private final String m_TAG = \"auauauauau\";\r\n  /** Size of the buffer where the audio data is stored by Android */\r\n  private static final int BUFFER_SIZE =\r\n      AudioRecord.getMinBufferSize(SAMPLING_RATE_IN_HZ, CHANNEL_CONFIG, AUDIO_FORMAT)\r\n          * BUFFER_SIZE_FACTOR;\r\n\r\n  /** Signals whether a recording is in progress (true) or not (false). */\r\n  private final AtomicBoolean recordingInProgress = new AtomicBoolean(false);\r\n\r\n  private AudioRecord recorder = null;\r\n\r\n  private Thread recordingThread = null;\r\n\r\n  private Button startButton;\r\n\r\n  private Button stopButton;\r\n  private long m_nTimeStart = 0; // !< the current time start\r\n\r\n  @Override\r\n  public void onCreate(Bundle savedInstanceState) {\r\n    super.onCreate(savedInstanceState);\r\n    setContentView(R.layout.audio);\r\n\r\n    startButton = (Button) findViewById(R.id.btnStart);\r\n    startButton.setOnClickListener(\r\n        new View.OnClickListener() {\r\n          @Override\r\n          public void onClick(View v) {\r\n            startRecording();\r\n            startButton.setEnabled(false);\r\n            stopButton.setEnabled(true);\r\n          }\r\n        });\r\n\r\n    stopButton = (Button) findViewById(R.id.btnStop);\r\n    stopButton.setOnClickListener(\r\n        new View.OnClickListener() {\r\n          @Override\r\n          public void onClick(View v) {\r\n            stopRecording();\r\n            // startButton.setEnabled(true);\r\n            // stopButton.setEnabled(false);\r\n          }\r\n        });\r\n\r\n    if ((ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)\r\n            != PackageManager.PERMISSION_GRANTED)\r\n        || (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)\r\n            != PackageManager.PERMISSION_GRANTED)) {\r\n      ActivityCompat.requestPermissions(\r\n          this,\r\n          new String[] {\r\n            Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE\r\n          },\r\n          1);\r\n    } // .. checkSelfPermission\r\n    stopButton.setEnabled(true);\r\n  } // ..onCreate\r\n\r\n  @Override\r\n  protected void onResume() {\r\n    super.onResume();\r\n\r\n    //  startButton.setEnabled(true);\r\n    stopButton.setEnabled(true);\r\n  }\r\n\r\n  @Override\r\n  protected void onPause() {\r\n    super.onPause();\r\n\r\n    stopRecording();\r\n  }\r\n\r\n  private void startRecording() {\r\n    recorder =\r\n        new AudioRecord(\r\n            MediaRecorder.AudioSource.MIC,\r\n            SAMPLING_RATE_IN_HZ,\r\n            CHANNEL_CONFIG,\r\n            AUDIO_FORMAT,\r\n            BUFFER_SIZE);\r\n    // start recording\r\n    recorder.startRecording();\r\n\r\n    recordingInProgress.set(true);\r\n    // create thread that reads buffer\r\n    recordingThread = new Thread(new RecordingRunnable(), \"Recording Thread\");\r\n    recordingThread.start();\r\n    m_nTimeStart = java.lang.System.currentTimeMillis();\r\n  }\r\n\r\n  private void stopRecording() {\r\n    if (null == recorder) {\r\n      return;\r\n    }\r\n\r\n    recordingInProgress.set(false);\r\n\r\n    recorder.stop();\r\n    recorder.release();\r\n\r\n    recorder = null;\r\n\r\n    recordingThread = null;\r\n  }\r\n\r\n  private class RecordingRunnable implements Runnable {\r\n\r\n    @Override\r\n    public void run() {\r\n      boolean bRunAgain = true;\r\n      while (bRunAgain) {\r\n        String filenamename = m_nTimeStart + \".pcm\";\r\n        Log.i(m_TAG, \"created new file : \" + filenamename);\r\n        final File file =\r\n            new File(Environment.getExternalStorageDirectory() + \"/SoundRecorder\", filenamename);\r\n        final ByteBuffer buffer = ByteBuffer.allocateDirect(BUFFER_SIZE);\r\n        //\r\n        try {\r\n          FileOutputStream outStream = new FileOutputStream(file, false);\r\n          while (recordingInProgress.get()) {\r\n            int result = recorder.read(buffer, BUFFER_SIZE);\r\n            if (result < 0) {\r\n              // throw - stopped? what about atomic boolean?\r\n              Log.e(m_TAG, \"result found \" + Integer.toString(result));\r\n              bRunAgain = false;\r\n              break;\r\n            }\r\n            outStream.write(buffer.array(), 0, BUFFER_SIZE);\r\n            buffer.clear();\r\n            //\r\n            // check if the next file is coming up:\r\n            if ((java.lang.System.currentTimeMillis() - m_nTimeStart) > RECORD_TIME_MS) {\r\n              m_nTimeStart = java.lang.System.currentTimeMillis();\r\n              break;\r\n            }\r\n          }\r\n        } catch (IOException e) {\r\n          throw new RuntimeException(\"Writing of recorded audio failed\", e);\r\n        }\r\n      } // ..while bRunAgain\r\n    }\r\n\r\n    private String getBufferReadFailureReason(int errorCode) {\r\n      switch (errorCode) {\r\n        case AudioRecord.ERROR_INVALID_OPERATION:\r\n          return \"ERROR_INVALID_OPERATION\";\r\n        case AudioRecord.ERROR_BAD_VALUE:\r\n          return \"ERROR_BAD_VALUE\";\r\n        case AudioRecord.ERROR_DEAD_OBJECT:\r\n          return \"ERROR_DEAD_OBJECT\";\r\n        case AudioRecord.ERROR:\r\n          return \"ERROR\";\r\n        default:\r\n          return \"Unknown (\" + errorCode + \")\";\r\n      }\r\n    }\r\n  }\r\n}\r\n"
    }
}


[Trace - 17:14:48] Sending request 'textDocument/documentSymbol - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java"
    }
}


[Trace - 17:14:48] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:48 >> initialized"
}


[Info  - 17:14:48] 4 авг. 2021 г., 17:14:48 >> initialized
[Trace - 17:14:49] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:49 Workspace initialized in 1488ms"
}


[Info  - 17:14:49] 4 авг. 2021 г., 17:14:49 Workspace initialized in 1488ms
[Trace - 17:14:49] Received notification 'language/status'.
Params: {
    "type": "Started",
    "message": "LightWeightServiceReady"
}


[Trace - 17:14:49] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:49 >> initialization job finished"
}


[Info  - 17:14:49] 4 авг. 2021 г., 17:14:49 >> initialization job finished
[Trace - 17:14:49] Received request 'client/registerCapability - (1)'.
Params: {
    "registrations": [
        {
            "id": "9f852a46-7ae6-4ebc-b31a-b0e553cbf3ea",
            "method": "textDocument/completion",
            "registerOptions": {
                "resolveProvider": true,
                "triggerCharacters": [
                    ".",
                    "@",
                    "#",
                    "*"
                ]
            }
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (1)'. Processing request took 1ms
No result returned.


[Trace - 17:14:49] Received request 'client/registerCapability - (2)'.
Params: {
    "registrations": [
        {
            "id": "ff77d5d1-a441-47fd-877f-33999dad122f",
            "method": "textDocument/definition"
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (2)'. Processing request took 1ms
No result returned.


[Trace - 17:14:49] Received request 'client/registerCapability - (3)'.
Params: {
    "registrations": [
        {
            "id": "5f72f7dc-4144-43e2-8a2f-80581e5f7ac4",
            "method": "textDocument/typeDefinition"
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (3)'. Processing request took 1ms
No result returned.


[Trace - 17:14:49] Received request 'client/registerCapability - (4)'.
Params: {
    "registrations": [
        {
            "id": "4b34d037-717e-4264-ae3e-40c3cdc168ba",
            "method": "textDocument/foldingRange"
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (4)'. Processing request took 1ms
No result returned.


[Trace - 17:14:49] Received request 'client/registerCapability - (5)'.
Params: {
    "registrations": [
        {
            "id": "442ece80-a9f9-4117-ab10-c2e9b220ff65",
            "method": "textDocument/selectionRange"
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (5)'. Processing request took 0ms
No result returned.


[Trace - 17:14:49] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:49 >> registerFeature 'workspace/didChangeWatchedFiles'"
}


[Info  - 17:14:49] 4 авг. 2021 г., 17:14:49 >> registerFeature 'workspace/didChangeWatchedFiles'
[Trace - 17:14:49] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:49 >> registerFeature 'workspace/didChangeWatchedFiles'"
}


[Info  - 17:14:49] 4 авг. 2021 г., 17:14:49 >> registerFeature 'workspace/didChangeWatchedFiles'
[Trace - 17:14:49] Received request 'client/registerCapability - (6)'.
Params: {
    "registrations": [
        {
            "id": "0cb9dfa3-d65e-47b6-85bc-e9bb101af586",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "**/*.java"
                    },
                    {
                        "globPattern": "**/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/**"
                    }
                ]
            }
        }
    ]
}


[Trace - 17:14:49] Sending response 'client/registerCapability - (6)'. Processing request took 1ms
No result returned.


[Trace - 17:14:49] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:49 >> workspace/didChangeConfiguration"
}


[Info  - 17:14:49] 4 авг. 2021 г., 17:14:49 >> workspace/didChangeConfiguration
[Trace - 17:14:50] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:50 >> document/didOpen"
}


[Info  - 17:14:50] 4 авг. 2021 г., 17:14:50 >> document/didOpen
[Trace - 17:14:50] Sending request 'textDocument/foldingRange - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java"
    }
}


[Trace - 17:14:50] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:50 >> document/documentSymbol"
}


[Info  - 17:14:50] 4 авг. 2021 г., 17:14:50 >> document/documentSymbol
[Trace - 17:14:50] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:50 >> document/foldingRange"
}


[Info  - 17:14:50] 4 авг. 2021 г., 17:14:50 >> document/foldingRange
[Trace - 17:14:50] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:50 Reconciled 1. Took 0 ms"
}


[Info  - 17:14:50] 4 авг. 2021 г., 17:14:50 Reconciled 1. Took 0 ms
[Trace - 17:14:50] Received response 'textDocument/foldingRange - (2)' in 694ms.
Result: [
    {
        "startLine": 0,
        "endLine": 14,
        "kind": "comment"
    },
    {
        "startLine": 36,
        "endLine": 36,
        "kind": "comment"
    },
    {
        "startLine": 46,
        "endLine": 51,
        "kind": "comment"
    },
    {
        "startLine": 55,
        "endLine": 55,
        "kind": "comment"
    },
    {
        "startLine": 60,
        "endLine": 60,
        "kind": "comment"
    },
    {
        "startLine": 18,
        "endLine": 34,
        "kind": "imports"
    },
    {
        "startLine": 37,
        "endLine": 213
    },
    {
        "startLine": 73,
        "endLine": 111
    },
    {
        "startLine": 92,
        "endLine": 96
    },
    {
        "startLine": 90,
        "endLine": 97
    },
    {
        "startLine": 81,
        "endLine": 85
    },
    {
        "startLine": 79,
        "endLine": 86
    },
    {
        "startLine": 105,
        "endLine": 107
    },
    {
        "startLine": 102,
        "endLine": 109
    },
    {
        "startLine": 114,
        "endLine": 119
    },
    {
        "startLine": 122,
        "endLine": 126
    },
    {
        "startLine": 128,
        "endLine": 144
    },
    {
        "startLine": 146,
        "endLine": 159
    },
    {
        "startLine": 147,
        "endLine": 149
    },
    {
        "startLine": 161,
        "endLine": 212
    },
    {
        "startLine": 164,
        "endLine": 196
    },
    {
        "startLine": 192,
        "endLine": 194
    },
    {
        "startLine": 166,
        "endLine": 195
    },
    {
        "startLine": 177,
        "endLine": 182
    },
    {
        "startLine": 187,
        "endLine": 190
    },
    {
        "startLine": 173,
        "endLine": 191
    },
    {
        "startLine": 198,
        "endLine": 211
    },
    {
        "startLine": 208,
        "endLine": 209
    },
    {
        "startLine": 199,
        "endLine": 210
    },
    {
        "startLine": 200,
        "endLine": 201
    },
    {
        "startLine": 202,
        "endLine": 203
    },
    {
        "startLine": 204,
        "endLine": 205
    },
    {
        "startLine": 206,
        "endLine": 207
    }
]


[Trace - 17:14:50] Received response 'textDocument/documentSymbol - (1)' in 2503ms.
Result: [
    {
        "name": "com.example.audiorecord",
        "kind": 4,
        "range": {
            "start": {
                "line": 16,
                "character": 0
            },
            "end": {
                "line": 16,
                "character": 32
            }
        },
        "selectionRange": {
            "start": {
                "line": 16,
                "character": 0
            },
            "end": {
                "line": 16,
                "character": 32
            }
        },
        "detail": ""
    },
    {
        "name": "AudioRecordActivity",
        "kind": 5,
        "range": {
            "start": {
                "line": 36,
                "character": 0
            },
            "end": {
                "line": 213,
                "character": 1
            }
        },
        "selectionRange": {
            "start": {
                "line": 37,
                "character": 13
            },
            "end": {
                "line": 37,
                "character": 32
            }
        },
        "detail": "",
        "children": [
            {
                "name": "SAMPLING_RATE_IN_HZ",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 39,
                        "character": 2
                    },
                    "end": {
                        "line": 39,
                        "character": 55
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 39,
                        "character": 27
                    },
                    "end": {
                        "line": 39,
                        "character": 46
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "RECORD_TIME_MS",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 40,
                        "character": 2
                    },
                    "end": {
                        "line": 40,
                        "character": 50
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 40,
                        "character": 27
                    },
                    "end": {
                        "line": 40,
                        "character": 41
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "CHANNEL_CONFIG",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 42,
                        "character": 2
                    },
                    "end": {
                        "line": 42,
                        "character": 72
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 42,
                        "character": 27
                    },
                    "end": {
                        "line": 42,
                        "character": 41
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "AUDIO_FORMAT",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 44,
                        "character": 2
                    },
                    "end": {
                        "line": 44,
                        "character": 73
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 44,
                        "character": 27
                    },
                    "end": {
                        "line": 44,
                        "character": 39
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "BUFFER_SIZE_FACTOR",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 46,
                        "character": 2
                    },
                    "end": {
                        "line": 52,
                        "character": 50
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 52,
                        "character": 27
                    },
                    "end": {
                        "line": 52,
                        "character": 45
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "m_TAG",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 54,
                        "character": 2
                    },
                    "end": {
                        "line": 54,
                        "character": 44
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 54,
                        "character": 23
                    },
                    "end": {
                        "line": 54,
                        "character": 28
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "BUFFER_SIZE",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 55,
                        "character": 2
                    },
                    "end": {
                        "line": 58,
                        "character": 31
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 56,
                        "character": 27
                    },
                    "end": {
                        "line": 56,
                        "character": 38
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recordingInProgress",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 60,
                        "character": 2
                    },
                    "end": {
                        "line": 61,
                        "character": 77
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 61,
                        "character": 30
                    },
                    "end": {
                        "line": 61,
                        "character": 49
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recorder",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 63,
                        "character": 2
                    },
                    "end": {
                        "line": 63,
                        "character": 38
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 63,
                        "character": 22
                    },
                    "end": {
                        "line": 63,
                        "character": 30
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recordingThread",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 65,
                        "character": 2
                    },
                    "end": {
                        "line": 65,
                        "character": 40
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 65,
                        "character": 17
                    },
                    "end": {
                        "line": 65,
                        "character": 32
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "startButton",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 67,
                        "character": 2
                    },
                    "end": {
                        "line": 67,
                        "character": 29
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 67,
                        "character": 17
                    },
                    "end": {
                        "line": 67,
                        "character": 28
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "stopButton",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 69,
                        "character": 2
                    },
                    "end": {
                        "line": 69,
                        "character": 28
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 69,
                        "character": 17
                    },
                    "end": {
                        "line": 69,
                        "character": 27
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "m_nTimeStart",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 70,
                        "character": 2
                    },
                    "end": {
                        "line": 70,
                        "character": 61
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 70,
                        "character": 15
                    },
                    "end": {
                        "line": 70,
                        "character": 27
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "onCreate(Bundle)",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 72,
                        "character": 2
                    },
                    "end": {
                        "line": 111,
                        "character": 17
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 73,
                        "character": 14
                    },
                    "end": {
                        "line": 73,
                        "character": 22
                    }
                },
                "detail": " : void",
                "children": [
                    {
                        "name": "new OnClickListener() {...}",
                        "kind": 5,
                        "range": {
                            "start": {
                                "line": 79,
                                "character": 8
                            },
                            "end": {
                                "line": 86,
                                "character": 9
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 79,
                                "character": 12
                            },
                            "end": {
                                "line": 79,
                                "character": 32
                            }
                        },
                        "detail": "",
                        "children": [
                            {
                                "name": "onClick(View)",
                                "kind": 6,
                                "range": {
                                    "start": {
                                        "line": 80,
                                        "character": 10
                                    },
                                    "end": {
                                        "line": 85,
                                        "character": 11
                                    }
                                },
                                "selectionRange": {
                                    "start": {
                                        "line": 81,
                                        "character": 22
                                    },
                                    "end": {
                                        "line": 81,
                                        "character": 29
                                    }
                                },
                                "detail": " : void",
                                "children": []
                            }
                        ]
                    },
                    {
                        "name": "new OnClickListener() {...}",
                        "kind": 5,
                        "range": {
                            "start": {
                                "line": 90,
                                "character": 8
                            },
                            "end": {
                                "line": 97,
                                "character": 9
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 90,
                                "character": 12
                            },
                            "end": {
                                "line": 90,
                                "character": 32
                            }
                        },
                        "detail": "",
                        "children": [
                            {
                                "name": "onClick(View)",
                                "kind": 6,
                                "range": {
                                    "start": {
                                        "line": 91,
                                        "character": 10
                                    },
                                    "end": {
                                        "line": 96,
                                        "character": 11
                                    }
                                },
                                "selectionRange": {
                                    "start": {
                                        "line": 92,
                                        "character": 22
                                    },
                                    "end": {
                                        "line": 92,
                                        "character": 29
                                    }
                                },
                                "detail": " : void",
                                "children": []
                            }
                        ]
                    }
                ]
            },
            {
                "name": "onResume()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 113,
                        "character": 2
                    },
                    "end": {
                        "line": 119,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 114,
                        "character": 17
                    },
                    "end": {
                        "line": 114,
                        "character": 25
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "onPause()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 121,
                        "character": 2
                    },
                    "end": {
                        "line": 126,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 122,
                        "character": 17
                    },
                    "end": {
                        "line": 122,
                        "character": 24
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "startRecording()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 128,
                        "character": 2
                    },
                    "end": {
                        "line": 144,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 128,
                        "character": 15
                    },
                    "end": {
                        "line": 128,
                        "character": 29
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "stopRecording()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 146,
                        "character": 2
                    },
                    "end": {
                        "line": 159,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 146,
                        "character": 15
                    },
                    "end": {
                        "line": 146,
                        "character": 28
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "RecordingRunnable",
                "kind": 5,
                "range": {
                    "start": {
                        "line": 161,
                        "character": 2
                    },
                    "end": {
                        "line": 212,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 161,
                        "character": 16
                    },
                    "end": {
                        "line": 161,
                        "character": 33
                    }
                },
                "detail": "",
                "children": [
                    {
                        "name": "run()",
                        "kind": 6,
                        "range": {
                            "start": {
                                "line": 163,
                                "character": 4
                            },
                            "end": {
                                "line": 196,
                                "character": 5
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 164,
                                "character": 16
                            },
                            "end": {
                                "line": 164,
                                "character": 19
                            }
                        },
                        "detail": " : void",
                        "children": []
                    },
                    {
                        "name": "getBufferReadFailureReason(int)",
                        "kind": 6,
                        "range": {
                            "start": {
                                "line": 198,
                                "character": 4
                            },
                            "end": {
                                "line": 211,
                                "character": 5
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 198,
                                "character": 19
                            },
                            "end": {
                                "line": 198,
                                "character": 45
                            }
                        },
                        "detail": " : String",
                        "children": []
                    }
                ]
            }
        ]
    }
]


[Trace - 17:14:51] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:51 begin problem for /AudioRecordActivity.java"
}


[Info  - 17:14:51] 4 авг. 2021 г., 17:14:51 begin problem for /AudioRecordActivity.java
[Trace - 17:14:51] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:51 0 problems reported for /AudioRecordActivity.java"
}


[Info  - 17:14:51] 4 авг. 2021 г., 17:14:51 0 problems reported for /AudioRecordActivity.java
[Trace - 17:14:51] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///E:/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java",
    "diagnostics": []
}


[Trace - 17:14:51] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:51 Validated 1. Took 636 ms"
}


[Info  - 17:14:51] 4 авг. 2021 г., 17:14:51 Validated 1. Took 636 ms
[Trace - 17:14:54] Sending request 'textDocument/documentSymbol - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///e%3A/PROGRAMMS/Android/android-audiorecord-sample/app/src/main/java/com/example/audiorecord/AudioRecordActivity.java"
    }
}


[Trace - 17:14:54] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:54 >> document/documentSymbol"
}


[Info  - 17:14:54] 4 авг. 2021 г., 17:14:54 >> document/documentSymbol
[Trace - 17:14:54] Received response 'textDocument/documentSymbol - (3)' in 37ms.
Result: [
    {
        "name": "com.example.audiorecord",
        "kind": 4,
        "range": {
            "start": {
                "line": 16,
                "character": 0
            },
            "end": {
                "line": 16,
                "character": 32
            }
        },
        "selectionRange": {
            "start": {
                "line": 16,
                "character": 0
            },
            "end": {
                "line": 16,
                "character": 32
            }
        },
        "detail": ""
    },
    {
        "name": "AudioRecordActivity",
        "kind": 5,
        "range": {
            "start": {
                "line": 36,
                "character": 0
            },
            "end": {
                "line": 213,
                "character": 1
            }
        },
        "selectionRange": {
            "start": {
                "line": 37,
                "character": 13
            },
            "end": {
                "line": 37,
                "character": 32
            }
        },
        "detail": "",
        "children": [
            {
                "name": "SAMPLING_RATE_IN_HZ",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 39,
                        "character": 2
                    },
                    "end": {
                        "line": 39,
                        "character": 55
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 39,
                        "character": 27
                    },
                    "end": {
                        "line": 39,
                        "character": 46
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "RECORD_TIME_MS",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 40,
                        "character": 2
                    },
                    "end": {
                        "line": 40,
                        "character": 50
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 40,
                        "character": 27
                    },
                    "end": {
                        "line": 40,
                        "character": 41
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "CHANNEL_CONFIG",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 42,
                        "character": 2
                    },
                    "end": {
                        "line": 42,
                        "character": 72
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 42,
                        "character": 27
                    },
                    "end": {
                        "line": 42,
                        "character": 41
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "AUDIO_FORMAT",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 44,
                        "character": 2
                    },
                    "end": {
                        "line": 44,
                        "character": 73
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 44,
                        "character": 27
                    },
                    "end": {
                        "line": 44,
                        "character": 39
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "BUFFER_SIZE_FACTOR",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 46,
                        "character": 2
                    },
                    "end": {
                        "line": 52,
                        "character": 50
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 52,
                        "character": 27
                    },
                    "end": {
                        "line": 52,
                        "character": 45
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "m_TAG",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 54,
                        "character": 2
                    },
                    "end": {
                        "line": 54,
                        "character": 44
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 54,
                        "character": 23
                    },
                    "end": {
                        "line": 54,
                        "character": 28
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "BUFFER_SIZE",
                "kind": 14,
                "range": {
                    "start": {
                        "line": 55,
                        "character": 2
                    },
                    "end": {
                        "line": 58,
                        "character": 31
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 56,
                        "character": 27
                    },
                    "end": {
                        "line": 56,
                        "character": 38
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recordingInProgress",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 60,
                        "character": 2
                    },
                    "end": {
                        "line": 61,
                        "character": 77
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 61,
                        "character": 30
                    },
                    "end": {
                        "line": 61,
                        "character": 49
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recorder",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 63,
                        "character": 2
                    },
                    "end": {
                        "line": 63,
                        "character": 38
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 63,
                        "character": 22
                    },
                    "end": {
                        "line": 63,
                        "character": 30
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "recordingThread",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 65,
                        "character": 2
                    },
                    "end": {
                        "line": 65,
                        "character": 40
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 65,
                        "character": 17
                    },
                    "end": {
                        "line": 65,
                        "character": 32
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "startButton",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 67,
                        "character": 2
                    },
                    "end": {
                        "line": 67,
                        "character": 29
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 67,
                        "character": 17
                    },
                    "end": {
                        "line": 67,
                        "character": 28
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "stopButton",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 69,
                        "character": 2
                    },
                    "end": {
                        "line": 69,
                        "character": 28
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 69,
                        "character": 17
                    },
                    "end": {
                        "line": 69,
                        "character": 27
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "m_nTimeStart",
                "kind": 8,
                "range": {
                    "start": {
                        "line": 70,
                        "character": 2
                    },
                    "end": {
                        "line": 70,
                        "character": 61
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 70,
                        "character": 15
                    },
                    "end": {
                        "line": 70,
                        "character": 27
                    }
                },
                "detail": "",
                "children": []
            },
            {
                "name": "onCreate(Bundle)",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 72,
                        "character": 2
                    },
                    "end": {
                        "line": 111,
                        "character": 17
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 73,
                        "character": 14
                    },
                    "end": {
                        "line": 73,
                        "character": 22
                    }
                },
                "detail": " : void",
                "children": [
                    {
                        "name": "new OnClickListener() {...}",
                        "kind": 5,
                        "range": {
                            "start": {
                                "line": 79,
                                "character": 8
                            },
                            "end": {
                                "line": 86,
                                "character": 9
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 79,
                                "character": 12
                            },
                            "end": {
                                "line": 79,
                                "character": 32
                            }
                        },
                        "detail": "",
                        "children": [
                            {
                                "name": "onClick(View)",
                                "kind": 6,
                                "range": {
                                    "start": {
                                        "line": 80,
                                        "character": 10
                                    },
                                    "end": {
                                        "line": 85,
                                        "character": 11
                                    }
                                },
                                "selectionRange": {
                                    "start": {
                                        "line": 81,
                                        "character": 22
                                    },
                                    "end": {
                                        "line": 81,
                                        "character": 29
                                    }
                                },
                                "detail": " : void",
                                "children": []
                            }
                        ]
                    },
                    {
                        "name": "new OnClickListener() {...}",
                        "kind": 5,
                        "range": {
                            "start": {
                                "line": 90,
                                "character": 8
                            },
                            "end": {
                                "line": 97,
                                "character": 9
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 90,
                                "character": 12
                            },
                            "end": {
                                "line": 90,
                                "character": 32
                            }
                        },
                        "detail": "",
                        "children": [
                            {
                                "name": "onClick(View)",
                                "kind": 6,
                                "range": {
                                    "start": {
                                        "line": 91,
                                        "character": 10
                                    },
                                    "end": {
                                        "line": 96,
                                        "character": 11
                                    }
                                },
                                "selectionRange": {
                                    "start": {
                                        "line": 92,
                                        "character": 22
                                    },
                                    "end": {
                                        "line": 92,
                                        "character": 29
                                    }
                                },
                                "detail": " : void",
                                "children": []
                            }
                        ]
                    }
                ]
            },
            {
                "name": "onResume()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 113,
                        "character": 2
                    },
                    "end": {
                        "line": 119,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 114,
                        "character": 17
                    },
                    "end": {
                        "line": 114,
                        "character": 25
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "onPause()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 121,
                        "character": 2
                    },
                    "end": {
                        "line": 126,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 122,
                        "character": 17
                    },
                    "end": {
                        "line": 122,
                        "character": 24
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "startRecording()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 128,
                        "character": 2
                    },
                    "end": {
                        "line": 144,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 128,
                        "character": 15
                    },
                    "end": {
                        "line": 128,
                        "character": 29
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "stopRecording()",
                "kind": 6,
                "range": {
                    "start": {
                        "line": 146,
                        "character": 2
                    },
                    "end": {
                        "line": 159,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 146,
                        "character": 15
                    },
                    "end": {
                        "line": 146,
                        "character": 28
                    }
                },
                "detail": " : void",
                "children": []
            },
            {
                "name": "RecordingRunnable",
                "kind": 5,
                "range": {
                    "start": {
                        "line": 161,
                        "character": 2
                    },
                    "end": {
                        "line": 212,
                        "character": 3
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 161,
                        "character": 16
                    },
                    "end": {
                        "line": 161,
                        "character": 33
                    }
                },
                "detail": "",
                "children": [
                    {
                        "name": "run()",
                        "kind": 6,
                        "range": {
                            "start": {
                                "line": 163,
                                "character": 4
                            },
                            "end": {
                                "line": 196,
                                "character": 5
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 164,
                                "character": 16
                            },
                            "end": {
                                "line": 164,
                                "character": 19
                            }
                        },
                        "detail": " : void",
                        "children": []
                    },
                    {
                        "name": "getBufferReadFailureReason(int)",
                        "kind": 6,
                        "range": {
                            "start": {
                                "line": 198,
                                "character": 4
                            },
                            "end": {
                                "line": 211,
                                "character": 5
                            }
                        },
                        "selectionRange": {
                            "start": {
                                "line": 198,
                                "character": 19
                            },
                            "end": {
                                "line": 198,
                                "character": 45
                            }
                        },
                        "detail": " : String",
                        "children": []
                    }
                ]
            }
        ]
    }
]


[Trace - 17:14:55] Sending request 'shutdown - (4)'.
[Trace - 17:14:55] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:55 >> shutdown"
}


[Info  - 17:14:55] 4 авг. 2021 г., 17:14:55 >> shutdown
[Trace - 17:14:55] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:55 >> exit"
}


[Info  - 17:14:55] 4 авг. 2021 г., 17:14:55 >> exit
[Trace - 17:14:55] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:55 Shutdown received... waking up main thread"
}


[Info  - 17:14:55] 4 авг. 2021 г., 17:14:55 Shutdown received... waking up main thread
[Trace - 17:14:55] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "4 авг. 2021 г., 17:14:55 class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is stopping:"
}


[Info  - 17:14:55] 4 авг. 2021 г., 17:14:55 class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is stopping:

What can I do about that?

airbagi avatar Aug 05 '21 08:08 airbagi

The logs seem to show the client (VS Code) sent a shutdown request near the bottom, which initiated the stopping of the language server. Not sure what would be causing this unintentionally. Does this happen consistently ? Is there a particular key combination or action this always happens with ?

rgrunber avatar Aug 06 '21 04:08 rgrunber

Yes, It happens every time I start Visual Studio Code. I can supply server logs, if it helps.

airbagi avatar Aug 06 '21 20:08 airbagi

@airbagi Could you try to set the following property:

"java.jdt.ls.vmargs": "-Dlog.level=ALL -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx3G -Xms512m",

snjeza avatar Aug 06 '21 21:08 snjeza

ok, I've set those params. I had only -Dlog.level=ALL previously set. What you need now?

Still have:

[Info  - 12:26:26] 7 авг. 2021 г., 12:26:26 >> shutdown
[Trace - 12:26:26] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "7 авг. 2021 г., 12:26:26 >> exit"
}

In server logs I also have this exception:

!ENTRY org.eclipse.buildship.core 2 2 2021-08-07 12:26:25.714
!MESSAGE Synchronize project android-audiorecord-sample failed due to an error in the referenced Gradle build.
!STACK 0
org.gradle.tooling.BuildException: Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.1.1-all.zip'.
	at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)

This is the only problem seems to be there

airbagi avatar Aug 07 '21 09:08 airbagi

@airbagi Could you attach a project example? You can also see Gradle-based Android projects are not supported

snjeza avatar Aug 07 '21 16:08 snjeza

I don't need gradle. The only thing I need from Language Server is to find definition or find implementation of some code. But it works untill the server is shutted down. I tested on several projects, but all of them are for Android, you think it is related?

airbagi avatar Aug 08 '21 12:08 airbagi

Could you attach a project or the build.gradle, .project, .classpath files and the .settings drectory?

snjeza avatar Aug 08 '21 15:08 snjeza

https://github.com/aahlenst/android-audiorecord-sample.git I checked on this project, for example.

project-settings.zip

classpath file has not been created

airbagi avatar Aug 09 '21 20:08 airbagi

So? Were you able to reproduce it?

airbagi avatar Aug 13 '21 11:08 airbagi

If I attempt to build the project as-is, I get :

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.0-rc-1-bin.zip'.
Build completed with 2 failures.
Build file '/home/rgrunber/sample-projects/android-audiorecord-sample/build.gradle' line: 63
A problem occurred evaluating root project 'android-audiorecord-sample'.
Cannot add task 'wrapper' as a task with that name already exists.

If I remove the wrapper task at the bottom of build.gradle, I get some other failure, but the language server never gets shut down.

With that said, is there any chance, the log we're looking at is of the Syntax Server ? It's actually expected to shut itself down like that once the client confirms the Standard Server has started. I can't seem to find "callHierarchyProvider": true in the initialize response of your logs, and that's a property the Standard Server would always set, in addition to some others.

rgrunber avatar Sep 02 '21 19:09 rgrunber

I also believe that the reason is gradlle-wrapper work. I also get those errors, but I can't disable processing of gradle. I checked off flags like: java.import.gradle.enabled: false java.import.gradle.wrapper.enabled: false

but still get those errors that you've mentioned: "Coudl not run phased build action..."

I build with Android Studio and don't need graddle-wrapper in Visual Studio Code. But I can't find the way to disable it.

airbagi avatar Sep 03 '21 09:09 airbagi

Noticed a little while ago you mentioned "But it works untill the server is shutted down." . If that's the case, then it's likely because the lightweight server mode is providing enough completion, and of course because the standard server fails to start (build failure) the result is no completion.

Could you try setting java.server.launchMode to lightweight ? You can do that in VS Code settings, or by having a settings file at the following location :

$ cat ~/sample-projects/android-audiorecord-sample/.vscode/settings.json 
{
    "java.server.launchMode": "LightWeight"
}

I haven't had too much time to play with the project so maybe there's a way to build it properly. Also I guess this issue can be taken as a bug where we should downgrade the server launch mode if the build completely fails.

rgrunber avatar Sep 06 '21 17:09 rgrunber

Wow! It works, thank you very much. As I understand, it does not use gradle, so everything works fine.

I also has to mention, that I've tried to adapt that extension to correctly use gradle, but in fact it ignores system vars such as: JAVA_HOME, GRADLE_USER_HOME etc.. so I failed to do that. For example, gradlew build script works fine with that settings.

airbagi avatar Sep 07 '21 09:09 airbagi

I'll keep this issue open for now because it shows an actual issue that would be nice to solve. Specifically :

  1. Client java.server.launchMode mode is set to Hybrid (usually default)
  2. Lightweight & Standard servers starts up for a Java project and user has (temporary) functionality (because of the Lightweight server)
  3. If the build fails, the Standard server still seems to respond with ServiceReady, and clients (eg. VS Code) use this to change the state to standard, shutting down the Lightweight server (since it's assumed the Standard server will take over)

I think we need to get access to whether the build succeeded/failed on the server side, and send the appropriate notification (Error?).

rgrunber avatar Sep 09 '21 14:09 rgrunber

  1. If the build fails, the Standard server still seems to respond with ServiceReady, and clients (eg. VS Code) use this to change the state to standard, shutting down the Lightweight server (since it's assumed the Standard server will take over) I think we need to get access to whether the build succeeded/failed on the server side, and send the appropriate notification (Error?).

+1

When importing a gradle project, GradleProjectImporter silently eats the exceptions that occur during the import phase so that the "Initialize Workspace" job in InitHandler does not fail and always sends a "Ready" status. It doesn't reflect the server status correctly.

https://github.com/eclipse/eclipse.jdt.ls/blob/7f393975b11ccfc03b3a5dc13f585855a5885461/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleProjectImporter.java#L302-L312

testforstephen avatar Sep 10 '21 02:09 testforstephen

And I again has to mention, for me its impossible to run correctly Gradle build, because it ignores either system var GRADLE_USER_HOME or internal vscode setting java.import.gradle.user.home

airbagi avatar Sep 10 '21 08:09 airbagi

android gradle project is not supported yet, that's a known issue.

testforstephen avatar Sep 10 '21 11:09 testforstephen